home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEV / C-H / CMacPrimer.cpt / ShowPICT ƒ / showPICT.c < prev   
C/C++ Source or Header  |  1989-12-16  |  1KB  |  73 lines

  1. #define BASE_RES_ID            400
  2. #define NIL_POINTER            0L
  3. #define MOVE_TO_FRONT        -1L
  4. #define REMOVE_ALL_EVENTS    0
  5.  
  6. PicHandle    gThePicture;
  7. WindowPtr    gPictureWindow;
  8.  
  9. main()
  10. {
  11.     ToolBoxInit();
  12.     WindowInit();
  13.     LoadPicture();
  14.     DrawMyPicture(gThePicture, gPictureWindow);
  15.     while(!Button());
  16. }
  17.  
  18. ToolBoxInit()
  19. {
  20.     InitGraf(&thePort);
  21.     InitFonts();
  22.     FlushEvents(everyEvent,REMOVE_ALL_EVENTS);
  23.     InitWindows();
  24.     InitMenus();
  25.     TEInit();
  26.     InitDialogs(NIL_POINTER);
  27.     InitCursor();
  28. }
  29.  
  30. WindowInit()
  31. {
  32.     gPictureWindow = GetNewWindow(BASE_RES_ID,NIL_POINTER,
  33.         MOVE_TO_FRONT);
  34.     ShowWindow(gPictureWindow);
  35.     SetPort(gPictureWindow);
  36. }
  37.  
  38. LoadPicture()
  39. {
  40.     gThePicture = GetPicture(BASE_RES_ID);
  41. }
  42.  
  43. DrawMyPicture(thePicture, pictureWindow)
  44. PicHandle    thePicture;
  45. WindowPtr    pictureWindow;
  46. {
  47.     Rect    myRect;
  48.     
  49.     myRect = pictureWindow->portRect;
  50.     CenterPict(thePicture, &myRect);
  51.     DrawPicture(thePicture, &myRect);
  52. }
  53.  
  54. CenterPict(thePicture, myRectPtr)
  55. PicHandle    thePicture;
  56. Rect        *myRectPtr;
  57. {
  58.     Rect windRect, pictureRect;
  59.     
  60.     windRect= *myRectPtr;
  61.     pictureRect = (**(thePicture)).picFrame;
  62.     myRectPtr->top = (windRect.bottom - windRect.top -
  63.         (pictureRect.bottom - pictureRect.top))/2 +
  64.         windRect.top;
  65.     myRectPtr->bottom = myRectPtr->top +
  66.         (pictureRect.bottom - pictureRect.top);
  67.     myRectPtr->left = (windRect.right - windRect.left -
  68.         (pictureRect.right - pictureRect.left))/2 +
  69.         windRect.left;    
  70.     myRectPtr->right = myRectPtr->left + (pictureRect.right - 
  71.         pictureRect.left);
  72. }
  73.